﻿
@{
    ViewBag.Title = "Quản trị ứng dụng";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
<div class="content">
    <div class="clear"></div>
    <table style="width: 100%">
        <tr>
            <td style="height: 40px;">
                <div id="nav"><a href="/Application/Index" title="">@ViewBag.Title.ToUpper()</a> </div>
            </td>
        </tr>
        <tr>
            <td style="">
                <div style="width: 100%;">
                    <div>
                        <div class="col-md-2" style="text-align:right;">
                            <label class="labels">Tên ứng dụng</label>
                        </div>
                        <div class="col-md-4">
                            <input type="text" class="txtsearch TextBoxContent" style="width: 100% !important" id="input-appname" name="appname">
                        </div>
                        <div class="col-md-2" style="text-align:right;">
                            <label class="labels">Mã ứng dụng</label>
                        </div>
                        <div class="col-md-4">
                            <input type="text" class="txtsearch TextBoxContent" style="width: 100% !important" id="input-appcode" name="appcode">
                        </div>
                    </div>
                    <div>
                        <div style="height: 10px;"></div>
                        <div class="col-md-12">

                            <div style="padding-top: 10px; text-align: center">
                                <div class="col-md-12">
                                    <span class="input-group-btn">
                                        <button class="btn btn-primary" type="button" onclick="return btnSearchClick();">
                                            <span class="glyphicon glyphicon-search"></span>Tìm kiếm
                                        </button>
                                        <button type="button" id="app_add" style="margin-left: 10px;" class="btn btn-primary" value="Thêm mới"><span class="glyphicon glyphicon-plus"></span>Thêm ứng dụng</button>                                        
                                    </span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <div id="app-list" style="margin-top:10px;">
                    @{
                        Html.RenderPartial("_AppList");
                    }
                </div>
            </td>
        </tr>
    </table>
</div>

<script type="text/javascript">
    function btnSearchClick() {
        OnCriteria(0);
    }
    $(document).ready(function () {
        $('#app_add').bind('click', function (event) {
            prepareCreateOrUpdate(0,'Thêm mới Ứng dụng');
        });        

    });

    function prepareCreateOrUpdate(appId,dlgTitle) {
        $('#app-model-container')
              .load("/Application/actionPrepareCreateOrUpdateApp", { appId: appId }, function () {
                  $(this).dialog({
                      draggable: true,
                      modal: true,
                      resizable: false,
                      width: 'auto',
                      title: dlgTitle,
                      minHeight: 75,
                      my: "center",
                      at: "center",
                      of: window,
                      buttons: [
                            {
                                text: "Lưu",
                                icons: {
                                    primary: "ui-icon-heart"
                                },
                                class: 'btn btn-primary',
                                click: function () {
                                    if (save) {
                                        var result = save();
                                        if (result) $(this).dialog("destroy");
                                    }
                                }
                            },
                            {
                                text: "Đóng",
                                icons: {
                                    primary: "ui-icon-close"
                                },
                                class: 'btn btn-primary',
                                click: function () {
                                    $(this).dialog("destroy");
                                }

                            }
                      ]
                  });
              });
    }

</script>